package com.gst.cloudygovernance.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.gst.cloudygovernance.R;

import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by YBH on 2017/12/18.
 */

public class DayFragmentAdapter extends BaseAdapter {
    private Context mContext;
    private Map<String,String> map = new HashMap<>();

    public DayFragmentAdapter(Context mContext) {
        this.mContext = mContext;
        initList();
    }

    private void initList() {
        for (int i = 0; i < 10; i++) {
            map.put(i+"","广州战场"+i+"号");
        }
    }

    @Override
    public int getCount() {
        return map == null ? 0 : map.size();
    }

    @Override
    public Object getItem(int position) {
        return map.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = View.inflate(mContext, R.layout.item_day, null);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        String s = map.get(position);
        //绑定数据
        holder.tvName.setText(map.get(position+""));
        holder.tvDate.setText(map.get(position+""));
        holder.tvTime.setText(map.get(position+""));
        return convertView;
    }

    static class ViewHolder {
        @Bind(R.id.tv_name)
        TextView tvName;
        @Bind(R.id.tv_date)
        TextView tvDate;
        @Bind(R.id.tv_time)
        TextView tvTime;
        @Bind(R.id.iv_go)
        ImageView ivGo;
        @Bind(R.id.ll_day)
        LinearLayout llDay;

        ViewHolder(View view) {
            ButterKnife.bind(this, view);
        }
    }
}
